package com.lagou.service;

import com.lagou.dao.AuthoCodeDao;
import com.lagou.dao.UserDao;
import com.lagou.edu.pojo.LagouAuthCode;
import com.lagou.edu.pojo.LagouUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.Optional;
import java.util.UUID;

@Service
@Transactional
public class UserService {
    @Autowired
    private UserDao userDao;

    public void insert(LagouUser user) {
        userDao.save(user);
    }

    public Optional<LagouUser> findByEmail(String email) {
        LagouUser user = new LagouUser();
        user.setEmail(email);
        Example<LagouUser> example = Example.of(user);
        Optional<LagouUser> one = userDao.findOne(example);
        return one;
    }
}

